export const homeData = {
  textList: [
    { bgColor: '#03A98E', name: '今日订单数量', num: 846, scale: '15.9', type: 1 },
    { bgColor: '#118AB4', name: '今日销售总额(元)', num: 2360.50, scale: '15.9', type: 2 },
    { bgColor: '#E27C21', name: '今日抽检项目', num: 65482, scale: '15.9', type: 1 },
    { bgColor: '#FF5566', name: '注册用户(个)', num: 185, scale: '15.9', type: 1 },
    { bgColor: '#9536D8', name: '入驻供应商', num: 2645, scale: '15.9', type: 1 },
    { bgColor: '#FF689E', name: '检测设备数量(台)', num: 4321, scale: '15.9', type: 1 },
    { bgColor: '#42BEAA', name: '高清摄像头(个)', num: 2000, scale: '15.9', type: 1 }
  ],
  controlsList: [
    { name: '供应商管理', path: '/supplier/index', image: require('@/assets/new_image/controls1.png') },
    { name: '用户管理', path: '/merchant/index', image: require('@/assets/new_image/controls2.png') },
    { name: '供应管理', path: '/relation/list', image: require('@/assets/new_image/controls3.png') },
    { name: '溯源管理', path: '/traceability/index', image: require('@/assets/new_image/controls4.png') },
    { name: '价格管理', path: '/price/summary', image: require('@/assets/new_image/controls5.png') },
    { name: '反馈管理', path: '/feedback/list', image: require('@/assets/new_image/controls6.png') },
    { name: '新闻管理', path: '/news/index', image: require('@/assets/new_image/controls7.png') }
  ],
  eventList: [
    { name: '供应商审核', num: 263, iconName: 'event1', path: '/supplier/join' },
    { name: '用户审核', num: 263, iconName: 'event2', path: '/merchant/index' },
    { name: '反馈处理', num: 263, iconName: 'event3', path: '/feedback/list' },
    { name: '预警事件', num: 263, iconName: 'event4', path: '/residues/index' }
  ],
  btnList: [
    { name: '本周', value: 'week' },
    { name: '本月', value: 'month' },
    { name: '今年', value: 'year' },
  ],
  lineData: {
    xAxisData: ["11-13", "11-14", "11-15", "11-16", "11-17", "11-18", "11-19"],
    numList: [120, 132, 101, 134, 90, 230, 210],
    priceList: [220, 182, 191, 234, 290, 330, 310]
  },
  ideaColumns: [    //  反馈意见处理
    { width: 180, label: '编号', prop: 'title' },
    { width: 160, label: '标题', prop: 'author' },
    { width: 120, label: '类型', prop: 'type' },
    { label: '反馈内容', prop: 'intro', showTooltip: true },
    { width: 120, label: '反馈来源', prop: 'source', slot: true },
  ],
  tableData: [
    { title: '202290434567655', author: '学校食堂卫生', type: '食品安全', intro: '食堂里有老鼠', source: 1 },
    { title: '202290434567655', author: '蔬菜有虫子', type: '食品质量', intro: '某一批蔬菜有虫子，x x x', source: 2 },
    { title: 202411280001, author: '希望小学', type: '食品安全', intro: '食品污染-微生物污染-黄曲霉',	source: 1 },
    { title: 202411280001, author: '希望小学', type: '食品安全', intro: '食品污染-微生物污染-黄曲霉',	source: 1 },
    { title: 202411280001, author: '希望小学', type: '食品安全', intro: '食品污染-微生物污染-黄曲霉',	source: 1 },
    { title: 202411280001, author: '希望小学', type: '食品安全', intro: '食品污染-微生物污染-黄曲霉',	source: 1 },
    { title: 202411280001, author: '希望小学', type: '食品安全', intro: '食品污染-微生物污染-黄曲霉',	source: 1 },
    { title: 202411280001, author: '希望小学', type: '食品安全', intro: '食品污染-微生物污染-黄曲霉',	source: 1 },
    { title: 202411280001, author: '希望小学', type: '食品安全', intro: '食品污染-微生物污染-黄曲霉',	source: 1 },
    { title: 202411280001, author: '希望小学', type: '食品安全', intro: '食品污染-微生物污染-黄曲霉',	source: 1 },
  ],
  shopBarData: [
    { value: 1048, name: '蔬菜' },
    { value: 735, name: '水果' },
    { value: 580, name: '生鲜' },
    { value: 484, name: '粮油' },
    { value: 300, name: '荤肉' }
  ],
  projectBarData: [
    { value: 1048, name: '农残残留' },
    { value: 735, name: '亚硝酸盐' },
    { value: 580, name: '重金属' },
    { value: 484, name: '二氧化硫' },
    { value: 300, name: '瘦肉精' }
  ],
  detectionColumns: [   //  检测合格率
    { width: 100, label: '排名', prop: 'title', slot: true },
    { label: '商品名称', prop: 'author' },
    { label: '指标', prop: 'type' },
    { label: '合格率', prop: 'intro' },
  ],
  detectionTableData: [
    { author: '土豆', type: '农药残留', intro: '96%' },
    { author: '白菜', type: '农药残留', intro: '96%' },
    { author: '大米', type: '农药残留', intro: '96%' },
    { author: '猪肉', type: '农药残留', intro: '96%' },
    { author: '花生油', type: '农药残留', intro: '96%' },
    { author: '花生油', type: '农药残留', intro: '96%' },
    { author: '花生油', type: '农药残留', intro: '96%' },
    { author: '花生油', type: '农药残留', intro: '96%' },
    { author: '花生油', type: '农药残留', intro: '96%' },
    { author: '花生油', type: '农药残留', intro: '96%' },
  ]
}
export const lineOption = (chartData) => {
  return {
    backgroundColor: '#fff',
    title: {
      text: ''
    },
    tooltip: {
      trigger: 'axis',
      backgroundColor: '#fff',
      textStyle: {
        color: '#666' // 文本颜色
      },
      extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3)'
    },
    legend: {
      data: ['订单数量', '成交金额'],
      top: 20,
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '8%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: chartData.xAxisData
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        name: '订单数量',
        type: 'line',
        stack: 'Total',
        data: chartData.numList,
        itemStyle: {
          color: '#5470C6'
        }
      },
      {
        name: '成交金额',
        type: 'line',
        stack: 'Total',
        data: chartData.priceList,
        itemStyle: {
          color: 'green'
        }
      },
    ]
  }
}
export const barOption = (chartData, title) => {
  return {
    title: {
      text: title.title,
      left: '34%',
      top: '38%',
      textStyle: {
        color: '#666',
        fontSize: '14px',
      },
      subtext: title.subtext,
      textAlign: 'center',
      subtextStyle: {
        color: '#222',
        fontSize: '24',
        fontWeight: 'bold',
      }
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      top: 'middle',
      orient: 'vertical',
      right: 0,
      itemGap: 24,
      formatter: function (name) {
        // 找到对应的数据项
        const data = chartData.find(item => item.name === name);
        if (data) {
          // 计算百分比
          const total = chartData.reduce((sum, item) => sum + item.value, 0);
          const percentage = ((data.value / total) * 100).toFixed(2) + '%';
          // 返回自定义的图例文本
          return `{legendText|${name}}`+percentage;
        }
        return name;
      }
    },
    textStyle: {
      // 使用 rich 样式来设置文本的样式
      rich: {
        legendText: {
          color: '#000',  // 设置文本颜色
          padding: [0, 10],  // 设置内边距，确保文本有一定的空间
          align: 'left',  // 设置文本左对齐
          width: 70,
          fontSize: 14,  // 设置文本的字体大小
        }
      }
    },
    series: [
      {
        type: 'pie',
        radius: ['50%', '80%'],
        center: ['35%', '50%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2,
          normal: {
            color: (colors) => {
              const colorList = ['#5470C6', '#91CC75', '#FAC858', '#EE6666', '#73C0DE']
              return colorList[colors.dataIndex]
            }
          }
        },
        label: {
          show: false,
          position: 'center'
        },
        labelLine: {
          show: false
        },
        data: chartData
      }
    ]
  }
}